<?php
date_default_timezone_set("PRC");

$dsn="mysql:Server=127.0.0.1;dbname=blog";
$db= new PDO($dsn, "root", "123456");
$db ->exec("set names utf8mb4");

$sql ="select * from admin order by admin_id desc";
$result =$db->query($sql);
$adminList =$result->fetchAll(PDO::FETCH_ASSOC);
?>

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="css/mian.css"/>
</head>
<body>
<div id="container">
    <div id="top">
        <h1>博客管理系统</h1>
        <div id="top_id">欢迎您：<?php echo $_SESSION['admin_name'] ?>
            <a href="logout.php">退出登录</a>
        </div>
    </div>
    <div id="left">
        <ul>
            <li><a href="category_list.php">分类管理</a></li>
            <li><a href="article_list.php">新闻管理</a></li>
            <li><a href="admin_list.php">管理员</a></li>
        </ul>
    </div>
    <div id="right">
        <div id="right_tao">
            <a href="article_list.php">首页</a>
            <a href="article_list.php">管理员管理</a>
            <a href="article_list.php">管理员列表</a>
        </div>
        <div id="table">
            <!--            <button class="but">全选</button>-->
            <!--            <a href="#">删除选中的任务</a>-->
            <a href="admin_add.php" id="p">增加管理员</a>
        </div>
        <div id="table_list">
            <table border="" cellspacing="" cellpadding="">
                <tr>
                    <th></th>
                    <th>管理员ID</th>
                    <th>管理员姓名</th>
                    <th>修改时间</th>
                    <th>增加时间</th>
                    <th>操作</th>
                </tr>
                <?php foreach ($adminList as  $value): ?>
                    <tr>
                        <td><input type="checkbox" class="task-checkbox" name="TaskId[]" value=""></td>
                        <td><?php echo $value['admin_id']; ?></td>
                        <td><?php echo $value['admin_name']; ?></td>
                        <td><?php echo date("Y-m-d H:i-s" ,$value['update_time']); ?></td>
                        <td><?php echo date("Y-m-d H:i-s" ,$value['add_time']); ?></td>
                        <td><a href="admin_edit.php?admin_id=<?php echo $value['admin_id']; ?>"> 编辑</a></td>
                    </tr>
                <?php endforeach; ?>
            </table>
        </div>
    </div>
</div>
</body>
</html>